$(document).ready(function(){
	
	$('.search input[type=text]').focus(function(){
				if($(this).val() == 'Search HR' ){
					$(this).val('');
				}	
			});
	$('.search input[type=text]').blur(function(){
				if($(this).val() == '' ){
					$(this).val('Search HR');
				}
	});
	
	// adjustments
	$('.nav li:last').addClass('home');
	
	// appends
	$('.home-content .left-column .content_column ul.news h4 a, .home-content .left-column .content_column ul.staff a, .tab-block-details a, .right_side-vacancies h4 a, .side-menu li ul li a, .inner-main-column .data li, .left-side .data li, .right-side li a, .not_found li, a.back-btn').prepend('<span class="icon"></span>');
	$('.home-content .quick-links li, .right_side-vacancies h4').append('<span class="icon"></span>')
	$( ".home-content .left-column .content_column ul.news h4 a, .home-content .left-column .content_column ul.staff a, .tab-block-details a, .right_side-vacancies h4 a, .side-menu li ul li a, .inner-main-column .data li, .left-side .data li, .right-side li a, a.back-btn" ).wrapInner( "<div class='text'></div>");
	$('.home-content .left-column .content_column ul.news h4 a span.icon, .home-content .left-column .content_column ul.staff a span.icon, .tab-block-details a span.icon, .right_side-vacancies h4 a span.icon, .side-menu li ul li a span.icon, .inner-main-column .data li span.icon, .left-side .data li span.icon, .right-side li a span.icon, a.back-btn span.icon').each(function() {
				$(this).parent().before(this);
	});
	
	
	
	
	$('.news_list li, .contact-us li, .search_results li').children('span.icon').remove();
	
	/// tabs 
	
	$(".tab-content").hide();
	$("ul#tabs li:first").addClass("active");
	$(".tab-content:first").show();
	$("ul#tabs li").click(function() {
	$("ul#tabs li").removeClass("active");
	$(this).addClass("active")
	$(".tab-content").hide();
	var activeTab = $(this).find("a").attr("href");
	$(activeTab).fadeIn();
	return false;
	});
	$(".side-modules-details").hide();
	$("ul#side-modules li:first").addClass("active");
	$(".side-modules-details:first").show();
	$("ul#side-modules li").click(function() {
	$("ul#side-modules li").removeClass("active");
	$(this).addClass("active")
	$(".side-modules-details").hide();
	var activeTab = $(this).find("a").attr("href");
	$(activeTab).fadeIn();
	return false;
	});
	
	$('.tabs-item').each(function(index, element) {
		if ($(this).children('.tab-block').length > 1 == true  ) {
			$(this).children('.tab-block').addClass('two-blocks');
		}
		else {
			
		}
	});
	$('.tab-block, .right_side-vacancies').each(function(index, element) {
		if ($(this).children('img').length > 0 == true  ) {
			
		}
		else {
			$(this).addClass('noImage');
		}
	});
	
	
	
 
	// tabs block condition 
	$(function(){
		  $(".tab-block.two-blocks .tab-block-details p").each(function(i){
			len=$(this).text().length;
			if(len>180)
			{
			  $(this).text($(this).text().substr(0,180)+'...');
			}
		  });
		  
		  $(".tab-block .tab-block-details p").each(function(i){
			len=$(this).text().length;
			if(len>500)
			{
			  $(this).text($(this).text().substr(0,500)+'...');
			}
		  });
		         
		});
		
	// text trim --
	// --------------------------------------------------------------
		$(".slide-details p").each(function(i){
			len=$(this).text().length;
			if(len>186)
			{
			  $(this).text($(this).text().substr(0, 186)+'...');
			}
		  });
		  $(".home-content .left-column .content_column ul.news p, .home-content .left-column .content_column ul.staff p").each(function(i){
			len=$(this).text().length;
			if(len>120)
			{
			  $(this).text($(this).text().substr(0, 120)+'...');
			}
		  });
		  
		  $(".right_side-vacancies p").each(function(i){
			len=$(this).text().length;
			if(len>140)
			{
			  $(this).text($(this).text().substr(0, 140)+'...');
			}
		  });
		  $(".vacancy p").each(function(i){
			len=$(this).text().length;
			if(len>285)
			{
			  $(this).text($(this).text().substr(0, 285)+' ...');
			}
		  });
		  $(".landing .item p").each(function(i){
			len=$(this).text().length;
			if(len>200)
			{
			  $(this).text($(this).text().substr(0, 200)+' ...');
			}
		  });
		  $(".left-side .data ul.news_list li .text p, .left-side .data ul.search_results li .text p").each(function(i){
			len=$(this).text().length;
			if(len>190)
			{
			  $(this).text($(this).text().substr(0, 190)+' ...');
			}
		  });
	// -------------------------------------------------------------
	$('.center-table tr:even td').css('background', '#f2f2f2');	
	
	// $('.news-block').wrapInner('<div class="news-text"></div>');
	/*$('.news-block img').each(function() {
				$(this).parent().before(this);
	});*/
	$('.copyright li:last-child').css('padding-right', '0');
	
	// accordion ---------------------------------------------------------
	
	
	
	
	$('.vacancy_title').click(function(){
			$('.vacancy_details').each(function(index, element) {
                    $(this).slideUp();
                });
				
				$('.vacancy').each(function(index, element) {
                    $(this).removeClass('open');
                });
				
				if(($(this).next('.vacancy_details').css('display') == 'none')) {
					$(this).next('.vacancy_details').slideToggle();
					$(this).parent('.vacancy').addClass('open');
				}
			});
	
	$('.nav li ul li').addClass('clearfix');
	var menuWidth = $('.nav li').width();
	$('.nav li').each(function(){
		if($(this).width()> 210) {
			$(this).children('ul').width($(this).width());
		}
	});
});

 $(window).load(function(){
      $('.flexslider').flexslider({
        animation: "fade",
		prevText: "",
		nextText: "",
        start: function(slider){
          $('body').removeClass('loading');
        }
      });
	  
	  var innerHeight = $('.inner-content').height();
	$('.inner-side-column, .inner-main-column, .left-side, .right-side').height(innerHeight);
	  
    });
	
/* ================================================
		Calendar & news 
   ================================================ */
$(window).load(function() {
		// top 
        $('.news-block:even p').each(function(index, element) {
            if ( $(this).children('i').length > 0 ) {
				$(this).children('i').css({float: 'right', marginRight: '0', marginLeft: '24px'});
				
		}
		else{
			$(this).children('span').css('width', 'auto');
		}
        });
		
		// bottom 
		$('.news-block:odd p').each(function(index, element) {
			if ( $(this).children('i').length > 0 ) {
				
				$(this).children('span').css({width: '435px'});
		}
		else{
			
			//$('.news-block:odd h4').css({float: 'left', width: 'auto'});
			$(this).children('span').css({width: 'auto'});
		}
		});
		
		$('.news-block p').each(function(){
			var y = $(this).width();
			var x = $(this).children('i').children('img').width()+26;
			$(this).children('.news-block p i + span').width(y-x);
			$(this).children('i').width($(this).children('i').children('img').width()+2);
			
			// console.log("image width" +'\n' + x);
			
			// console.log("paragraph" +'\n' + y);
		});
		
		$('.list-fake span.square').html('&#9642;');
    });